<?php

/**
 * Created by PhpStorm.
 * User: henry
 * Date: 2017/2/22
 * Time: 下午4:41
 */

namespace common\utils;

use Solarium\Client as Client;
use yii\base\Exception;

class SearchUtils
{
    /**
     * 获取关键词的所有子字符串
     * @param $keyWord
     * @return array|null
     */
    public static function  getAllSubStr($keyWord)
    {
        if (empty($keyWord)) {
            return null;
        }
        $subStrArray = [];
        $len = mb_strlen($keyWord, "utf-8");
        for ($i = 0; $i < $len - 1; $i++) {
            for ($j = $i + 2; $j <= $len; $j++) {
                array_push($subStrArray, mb_substr($keyWord, $i, $j, "utf-8"));
            }
        }
        return $subStrArray;
    }

}